home *** CD-ROM | disk | FTP | other *** search
/ No Sense / No Sense - Issue 1 (1996-02-05)(C-Lous)(AGA)[KS3.0].adf / Articles / GeSchyber35,1 < prev    next >
Text File  |  1978-02-24  |  3KB  |  106 lines

  1. \I[Make your own Chunky 2 Planar|By Scout|Section: Graphicians & Coders Pool]
  2. \F2\4\MMake yor own C2P
  3. \F3\2
  4. \C[ClipArts/pinnen.Chnk]
  5.   The basic idea of Chunky-to-Planar conversion is to convert one chunky-pixel (one byte containing the complete color value of one pixel) to bitplane-data. This is achieved by writing one bit of the chunky-pixel to each bitplane. That way, one can have a putpixel-routine that does all the work. However, the conversion is extremely slow. It does, for instance, write the same byte eight (!) times when drawing horizontal lines (one write (or rather 'or.b') per bit to be set). Isn't there any other way?
  6.  
  7.   Yes there is. If one would have a temporary buffer where one would draw the chunky-pixels (not converting them in any way), and a C2P-routine then would convert the whole buffer into bitplanes (writing data directly to the screen), there would be a tremendous speed-increase since the C2P-routine can deal with many pixels at once!
  8.  
  9.   The simplest (and slowest) C2P-routine grabs 8 pixels at a time. The more complex ones handle 16 pixels (or 32, but they then need a temporary buffer). The C2P conversion is handled through a magic process.
  10.  
  11. \C[ClipArts/pinnen.Chnk]
  12. \3Knowledge of a few special operations are required:
  13.  
  14. Rotation (90 degrees counterclockwise):
  15.  
  16. This has the following effect:
  17.  
  18. (Each letter represents a bit in the byte)
  19. abcdefgh
  20. ijklmnop
  21.  
  22. Rot 1x1
  23.  
  24. bjdlfnhp
  25. aickemgo
  26.  
  27. The data is split up into 2x2 segments. Inside each segment, a 1x1 rotation is performed: a moves down, b moves left, i moves right, j moves up.
  28.  
  29. A 2x2 rotation means that the data is split up into 4x4 segments, and inside each segment 2x2 blocks (instead of single pixels) are moved. The order inside each 2x2 block shouldn't be changed.
  30. It is done like this:
  31.  
  32. abcd
  33. efgh
  34. ijkl
  35. mnop
  36.  
  37. Rot 2x2
  38.  
  39. cdkl
  40. ghop
  41. abij
  42. efmn
  43.  
  44. A 1x1 swap is performed like this:
  45.  
  46. ; d0 and d1 contains bit pattern
  47. ; Bit mask with every 2nd bit set
  48.         move.b  #$55,d7
  49.         move.b  d0,d2
  50. ; Mask out the bits changing byte
  51.         and.b   d7,d0
  52. ; Mask out the other ones in d2
  53.         eor.b   d0,d2
  54. ; Do the left-move
  55.         lsl.b   #1,d0
  56.         move.b  1,d3
  57. ; Mask out the bits not changing byte
  58.         and.b   d7,d3
  59. ; Mask out the other ones in d2
  60.         eor.b   d3,d1
  61. ; Do the right-move
  62.         lsr.b   #1,d0
  63. ; Do the up-move
  64.         or.b    d3,d0
  65. ; Do the down-move
  66.         or.b    d2,d1
  67.  
  68. Swap: 
  69.  
  70. This one is almost exactly like the rotation. It exchanges bits diagonally:
  71.  
  72. abcdefgh
  73. ijklmnop
  74.  
  75. Swap 2x1
  76.  
  77. abijefmn
  78. cdklghop
  79.  
  80. A 2x1 swap is done like this:
  81.  
  82. ; d0 and d1 contains bit pattern
  83. ; Bit mask: 00110011
  84.         move.b  #$33,d7
  85.         move.b  d0,d2
  86. ; Mask out the bits not moved
  87.         and.b   d7,d2
  88. ; Mask out the other ones
  89.         eor.b   d2,d0
  90. ; Move the bits left
  91.         lsl.b   #2,d2
  92.         move.b  d1,d3
  93. ; Mask out the bits moved
  94.         and.b   d7,d0
  95. ; Mask out the other ones
  96.         eor.b   d0,d3
  97. ; Move the bits right
  98.         lsr.b   #2,d3
  99. ; Insert the bits
  100.         or.b    d3,d0
  101. ; Insert the bits
  102.         or.b    d2,d1
  103.  
  104. \C[ClipArts/pinnen.Chnk]
  105.  
  106. \3\M\S[Articles/GeSchyber35,2]\2\3Next page please!